% This script get the efficient frontier by varying tolerance level w

converge = 0;
optR = [];
w = 0.06;
r_prev = 0;
alpha = 0.99;
w_v = [];
while converge == 0
    
    [optPort,FVAL,r,CVaR ] = CVaRoptimize( Yij, y',0.16/100,alpha, ...
    w, 0.2, 0);
    
    if r - r_prev <=0.0001
        converge = 1;
    end
    optR = [ optR; r];
    r_prev = r;
    w_v = [w_v; w];
    w = w + 0.005;
    
end

clear converge w r_prev alpha
fprintf('program terminated\n');